<template>
	<view class="incubate-apply" :style="{'height':height+'px'}">
		<view class="tips">请确保您填写资料的准确性，以便我方和您取得联系！</view>
		<view class="address-form">
			<form @submit="formSubmit">

				<view class="label-input">
					<text>企业名称</text>
					<input placeholder-style="font-size:28rpx" maxlength="64" v-model="companyName"
						@keyup="companyName=companyName.replace(/\s+/g,'')" placeholder="请输入" />

				</view>

				<view class="label-input isMargin">
					<text>联系人</text>
					<input placeholder-style="font-size:28rpx" maxlength="16"
						@keyup="realName=realName.replace(/\s+/g,'')" v-model="realName" placeholder="姓名(必填)" />
				</view>
				<view class="label-input ">
					<text>联系方式</text>
					<input placeholder-style="font-size:28rpx" maxlength="11" type="number"
						@keyup="contactNumber=contactNumber.replace(/\s+/g,'')" v-model="contactNumber"
						placeholder="联系电话(必填)" />
				</view>

				<view class="label-input isMargin" @click="checkVip">
					<text>是否会员</text>
					<input placeholder-style="font-size:28rpx" disabled maxlength="200" v-model="member"
						placeholder="请选择(必填)" />
					<image src="@/static/Chevron.png" mode=""></image>
				</view>

				<view class="label-input isMargin">
					<text class="area">备注</text>
					<textarea auto-height style="margin: 0 16rpx;" maxlength="200"
						@keyup="applyRemark=applyRemark.replace(/\s+/g,'')" v-model="applyRemark" placeholder="请输入" />
				</view>
			</form>
		</view>
		<view class="footer">
			<button type="primary" class="back-btn" @click="back">返回</button>
			<button type="primary" @click="submit" :style="{background:(inputAll?'#0B4E9E':'#CCCCCC')}">确定</button>
		</view>

	</view>
</template>

<script>
	import api from 'api/modules/touhang.js';
	export default {
		name: 'HaveProject',
		computed: {

			inputAll: function() {
				if (
					this.contactNumber &&
					this.member &&
					this.realName) {
					return true
				}
				return false
			}
		},
		onLoad(params) {
			let _this = this
			if (params) {
				this.projectId = params.projectId
			}
			uni.getSystemInfo({
				success(res) {
					_this.height = res.windowHeight
				}
			});
		},
		data() {
			return {
				companyName: '',
				contactNumber: '',
				inviterRealName: '',
				member: '',
				projectId: '',
				realName: '',
				applyRemark: ''
			}
		},
		methods: {
			checkVip() {
				uni.showActionSheet({
					itemList: ['是', '否'],
					success: (res) => {
						this.member = res.tapIndex == 0 ? '是' : '否'
					},

				});
			},
			back() {
				uni.navigateBack()
			},
			submit() {
				if (!this.inputAll) {
					return
				} else {
					if (!/^1([3456789])\d{9}$/.test(this.contactNumber)) {
						uni.showToast({
							title: '联系方式错误',
							icon: 'none'
						})
						return
					}
					api.applyBusinessIncubation({
						companyName: this.companyName,
						contactNumber: this.contactNumber,
						member: this.member == '是' ? true : false,
						realName: this.realName,
						applyRemark: this.applyRemark
					}).then(res => {
						uni.showToast({
							title: '申请成功',
							icon: 'none'
						})
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/views/service/touhang/Index'
							})
						}, 1500)
					})

				}

			}
		}
	}
</script>

<style lang="less" scoped>
	page {
		background-color: #F6F6F6;
	}
</style>
